package com.liyongjian.xhban.dal;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.liyongjian.xhban.model.UserFriendConfirm;
import com.liyongjian.xhban.model.emumm.VerifyState;

public interface UserFriendConfirmRepository
        extends PagingAndSortingRepository<UserFriendConfirm, Long> {

    @Query("select t from UserFriendConfirm t, User u where t.friendUserId=u.id and t.userId=:userId and t.state!=0 and u.state=1")
    Page<UserFriendConfirm> findFriendByUserId(@Param("userId") Long userId, Pageable pageable);

    UserFriendConfirm findByUserMsgId(Long userMsgId);

    int countByUserIdAndFriendUserIdAndState(Long userId, Long friendUserId, VerifyState state);
}
